import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:state_manager/view_model/counter_view_model.dart';

class DBJGoodsInfo extends StatefulWidget {
  const DBJGoodsInfo({Key? key}) : super(key: key);

  @override
  _DBJGoodsInfoState createState() => _DBJGoodsInfoState();
}

class _DBJGoodsInfoState extends State<DBJGoodsInfo> {
  @override
  Widget build(BuildContext context) {
    print('_DBJGoodsInfoState --- build');
    return Container(
      child: Consumer<DBJCounterViewModel>(
        builder: (cxt, viewModel, child) {
          print('_DBJGoodsInfoState --- Consumer --- build');
          return Text(
            '购物车信息：${viewModel.counter}',
            style: TextStyle(fontSize: 20, color: Colors.purple),
          );
        },
      ),
    );
  }
}
